package com.kly.smartbi.job.cycle;

import com.xxl.job.core.context.XxlJobHelper;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @author admin
 * @date 2025/4/16
 */
@Component
@Slf4j
public class SimpleXxlJob {


    /**
     * 1、简单任务示例（Bean模式）
     */
    @XxlJob("demoJobHandler")
    public void demoJobHandler() throws Exception {
        XxlJobHelper.log("XXL-JOB, Hello World.");

        for (int i = 0; i < 5; i++) {
            XxlJobHelper.log("beat at:" + i);
            TimeUnit.SECONDS.sleep(2);
            log.info("我是你的 beat at:" + i);
        }
        // default success
    }

    /**
     * 你好世界 定时任务
     */
    @XxlJob("helloWorldJobHandler")
    public void helloWorldJobHandler() throws Exception {
        XxlJobHelper.log("XXL-JOB, Hello World.");

       log.info("hello world， i love you");
    }
}
